package com.cn.service.impl;

import com.cn.mapper.UserMapper;
import com.cn.pojo.ShoppingCartItem;
import com.cn.pojo.User;

import com.cn.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author:王宇航
 * @create: 2023-05-18 11:51
 * @Description:
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserMapper userMapper;
    @Override
    public User loginUser(User user) {
        if (userMapper.loginUser(user) == null) {
            return null;
        }else {
            return  userMapper.loginUser(user);
        }
    }

    @Override
    public User searchByUserId(User user) {
        return userMapper.searchByUserId(user);
    }

    @Override
    public User searchMobile(User user) {
        return userMapper.searchMobile(user);
    }

    @Override
    public int insertUser(User user) {
        return userMapper.insertUser(user);
    }

    @Override
    public int editInfo(User user) {
        return userMapper.editInfo(user);
    }

    /*查询购物车数量*/
    @Override
    public int searchCartNumbers(ShoppingCartItem cart) {
        return userMapper.searchCartNumbers(cart);
    }

    @Override
    public void updateAddress(User user) {
        userMapper.updateAddress(user);
    }

    @Override
    public List<User> findAllUser() {
        return userMapper.findAllUser();
    }

    @Override
    public void logout(int userId) {
        userMapper.logout(userId);
    }


}
